<?php
/**
 * Created by PhpStorm.
 * User: superxing-cto
 * Date: 17/3/3
 * Time: 15:17
 */

namespace App\Models;

/**
 * Class Like
 * @property integer user_id
 * @property string type
 * @property integer type_id
 * @property integer to_user_id
 * @property User user
 * @property User toUser
 */
class Like extends ApplicationModel
{
    const TYPE_IN = 'in';
    const TYPE_OUT = 'out';
    protected $fillable = [
        'user_id',
        'type',
        'type_id',
        'to_user_id',
    ];

    public function user()
    {
        return $this->belongsTo(User::class);
    }

    public function toUser()
    {
        return $this->belongsTo(User::class, 'to_user_id');
    }

    public function dynamic()
    {
        return $this->belongsTo(Dynamic::class, 'type_id')->withTrashed();
    }

    public function video()
    {
        return $this->belongsTo(Video::class, 'type_id')->withTrashed();
    }
}